package com.health.userbackstage.utils;

import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class RegularExpression {

    //正则表达式判断手机号是否正确
    public static boolean determine(String phoneNumber){
        String regex = "^\\d{11}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(phoneNumber);
        boolean isMatched = matcher.find();
        return isMatched;
    }

    //正则表达式判断邮箱是否正确
    public static boolean determineEmail(String email){
        String regex = "\\w+@\\w+(\\.\\w{2,3})*\\.\\w{2,3}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(email);
        boolean isMatched = matcher.find();
        return isMatched;
    }

    //正则表达式判断身份证是否正确
    public static boolean determineIdCard(String idCard){
        String regex = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|10|11|12)(0[1-9]|[1-2]\\d|30|31)\\d{3}[0-9Xx]$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(idCard);
        boolean isMatched = matcher.find();
        return isMatched;
    }

    public static void main(String[] args) {
        boolean b = RegularExpression.determineEmail("874504892@qq.com");
        System.out.println(b);
    }

}
